package cn.earl.springboot.user.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import cn.earl.springboot.entity.User;

public interface UserRepository extends JpaRepository<User, Integer> {

	// http://shensuqiao.iteye.com/blog/2096114
	// 注意User是实体类名称，而不是表的名称
	@Query(value = "SELECT u FROM User u WHERE (username=?1 OR phone_number=?1) AND password=?2")
	public User findUserByUsernameOrPhone_numberAndPassword(String username, String password);

	// void deleteById(int id);
	public User findByUsername(String username);

	public boolean findStatusByUsername(String username);
	
	@Query("SELECT u FROM User u WHERE u.phone_number=?1")
	public User findUserByPhone_number(String phone_number);

}
